var e = getApp();

Page({
    data: {
        codeId: null,
        usedLog: [],
        usedLogPage: 1,
        usedLogLoading: !1,
        usedLogLoadFinished: !1
    },
    onLoad: function(e) {
        var a = this;
        e.code_id || wx.showToast({
            title: "升级码不存在",
            icon: "none",
            duration: 1500,
            success: function(e) {
                wx.redirectTo({
                    url: "/packageH/member/upgrade_code/index/index"
                });
            }
        }), wx.setNavigationBarTitle({
            title: "升级码使用记录"
        }), this.setData({
            codeId: e.code_id
        }, function() {
            a.getUsedLog();
        });
    },
    onReachBottom: function() {
        this.getUsedLog();
    },
    getUsedLog: function() {
        var a = this;
        if (!0 !== this.data.usedLogLoading && !0 !== this.data.usedLogLoadFinished) {
            this.setData({
                usedLogLoading: !0
            });
            var t = e.getNetAddresss("plugin.upgrade-code.Frontend.controllers.code.logs");
            e._getNetWork({
                url: t,
                data: {
                    id: this.data.codeId,
                    page: this.data.usedLogPage
                },
                success: function(e) {
                    var t = e.data, d = t.data, o = t.result, s = t.msg;
                    if (wx.stopPullDownRefresh(), 0 !== o) {
                        var i = {
                            usedLogLoading: !1,
                            usedLogPage: a.data.usedLogPage + 1
                        }, g = a.data.usedLog;
                        (d.last_page == d.current_page || d.data.length < d.per_page) && (i.usedLogLoadFinished = !0), 
                        g = g.concat(d.data), i.usedLog = g, a.setData(i);
                    } else wx.showToast({
                        title: s,
                        duration: 1500,
                        mask: !1,
                        success: function(e) {
                            wx.navigateBack({
                                delta: 1
                            });
                        }
                    });
                }
            });
        }
    }
});